<?php
declare (strict_types=1);

namespace app\admin\controller\tally;

use app\admin\controller\CommonController;
use app\common\model\TallyContract;
use ffhome\frame\service\DictDataService;

class Contract extends CommonController
{
    protected $modelName = TallyContract::MODEL_NAME;
    protected $alias = 'c';

    protected function getExportHeader()
    {
        return [
            [lang('contract.number'), 'number'],
            [lang('contract.custom_name'), 'custom_name'],
            [lang('contract.article'), 'article'],
            [lang('contract.start_date'), 'start_date'],
            [lang('contract.end_date'), 'end_date'],
            [lang('contract.status'), 'status'],
            [lang('contract.contract_money'), 'contract_money'],
            [lang('contract.invoice'), 'invoice'],
            [lang('contract.invoice_money'), 'invoice_money'],
            [lang('contract.unit'), 'unit'],
            [lang('contract.collect_money'), 'collect_money'],
            [lang('contract.signer'), 'signer'],
            [lang('contract.sign_rate'), 'sign_rate'],
            [lang('contract.sign_money'), 'sign_money'],
            [lang('contract.sign_status'), 'sign_status'],
            [lang('contract.undertaker'), 'undertaker'],
            [lang('contract.undertake_rate'), 'undertake_rate'],
            [lang('contract.undertake_money'), 'undertake_money'],
            [lang('contract.undertake_status'), 'undertake_status'],
        ];
    }

    protected function convertExportData(&$list)
    {
        foreach ($list as &$vo) {
            $vo['status'] = DictDataService::getNameByValue($vo['status'], 'contract_status_list');
            $vo['invoice'] = DictDataService::getNameByValue($vo['invoice'], 'invoice_status_list');
            $vo['sign_status'] = DictDataService::getNameByValue($vo['sign_status'], 'settle_status_list');
            $vo['undertake_status'] = DictDataService::getNameByValue($vo['undertake_status'], 'settle_status_list');
            $vo['sign_rate'] = $vo['sign_rate'] . '%';
            $vo['undertake_rate'] = $vo['undertake_rate'] . '%';
        }
    }
}
